
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h3>session</h3>
<%
    //session 会话 客户浏览第一次请求服务器时，在服务器建议的临时对象（有效期30分钟）
    int sn = 1;
    if(session.getAttribute("num")==null){
        session.setAttribute("num",1);
    }else{
        sn = Integer.parseInt(session.getAttribute("num").toString())+1;
        session.setAttribute("num",sn);
    }
    out.print(String.format("session.num = %d",sn));
%>
<h3>application</h3>
<%
    int an = 0;
    if(application.getAttribute("num")==null){
        application.setAttribute("num",1);
    }else{
        an = Integer.parseInt(application.getAttribute("num").toString())+1;
        application.setAttribute("num",an);
    }
    out.print(String.format("application.num = %d",an));
%>
</body>
</html>
